import re


def solution(n, template_, titles):
    # 将模板中的通配符替换为正则表达式中的任意字符匹配模式
    pattern = re.sub(r'\{.*?\}', '.*', template_)
    # 编译正则表达式模式
    regex = re.compile(pattern)
    # 对每个标题进行匹配，并将结果转换为字符串列表
    result = [str(bool(regex.fullmatch(title))) for title in titles]
    # 将结果列表用逗号连接成一个字符串
    return ",".join(result)


if __name__ == "__main__":
    #  You can add more test cases here
    testTitles1 = ["adcdcefdfeffe", "adcdcefdfeff", "dcdcefdfeffe", "adcdcfe"]
    testTitles2 = ["CLSomGhcQNvFuzENTAMLCqxBdj", "CLSomNvFuXTASzENTAMLCqxBdj",
                   "CLSomFuXTASzExBdj", "CLSoQNvFuMLCqxBdj", "SovFuXTASzENTAMLCq", "mGhcQNvFuXTASzENTAMLCqx"]
    testTitles3 = ["abcdefg", "abefg", "efg"]

    print(solution(4, "ad{xyz}cdc{y}f{x}e", testTitles1)
          == "True,False,False,True")
    print(solution(6, "{xxx}h{cQ}N{vF}u{XTA}S{NTA}MLCq{yyy}",
                   testTitles2) == "False,False,False,False,False,True")
    print(solution(3, "a{bdc}efg", testTitles3) == "True,True,False")
